/**
 * 
 */
package utils.input;

import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author kasztan no!
 * 
 */
public class KeyboardListener implements KeyListener
{

	public KeyboardListener(Component keyPressDispatcher)
	{
		keyPressDispatcher.addKeyListener(this);
	}

	private void call(Object instance, Method callback, Object[] arguments)
	{
	}

	public void registerKey(char key, Object instance, Method callback,
			Object[] arguments)
	{
		try
		{
			// registerKey(key, this, this.getClass().getMethod("print", new
			// Class[0]), new Object[0]);
			callback.invoke(instance, arguments);
		} catch (IllegalArgumentException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void unregisterKey(char key)
	{
	}

	public void keyPressed(KeyEvent e)
	{
		// TODO Auto-generated method stub
		try
		{
			call(this, this.getClass().getMethod("unregisterKey",
					new Class[0]), new Object[0]);
		} catch (SecurityException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (NoSuchMethodException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

	}

	public void keyReleased(KeyEvent e)
	{
		// TODO Auto-generated method stub

	}

	public void keyTyped(KeyEvent e)
	{
		// TODO Auto-generated method stub

	}

}
